# CombinedImages_PixelValue.py # # Description: Take two images (2 files) as input # 1) Image A is the foreground object in front of a green screen # 2) Image B is the background # and investigate their content! # # Author: AL and AL # Date: 2024 # Import necessary Python Imaging Library (PIL) from PIL import Image # Open the file containing the foreground object with green screen -> A imageKidOpen = Image.open("kid-green.jpg") # Open the file containing the background -> B imageBeachOpen = Image.open("beach.jpg") # Get width and height of image kid-green.jpg widthKid = imageKidOpen.width heightKid = imageKidOpen.height print(f'Image kid-green.jpg is width {widthKid} pixels by height {heightKid} pixels') # Get width and height of image beach.jpg widthBeach = imageBeachOpen.width heightBeach = imageBeachOpen.height print(f'Image beach.jpg is width {widthBeach} pixels by height {heightBeach} pixels') # Load the content (pixels) of the file containing the # foreground object with green screen -> A imageKidLoaded = imageKidOpen.load() # Open and load the content (pixels) of file containing the background -> B imageBeachLoaded = imageBeachOpen.load() # What do image files contain? # What is at coordinates (0,0) of image A: 'kid-green.jpg'? print(f'Value of (0,0) of kid-green.jpg is {imageKidLoaded[0,0]}') # Close the image files imageKidOpen.close() imageBeachOpen.close()